package com.ding.delegate;

import java.util.List;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.runtime.Execution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class A implements JavaDelegate{
	
	@Autowired
	RuntimeService runtimeService;
	
	@Autowired
	RepositoryService repositoryService;
	
	@Override
	public void execute(DelegateExecution execution) throws Exception {

		//RuntimeService中存放的是启动过的流程,查找不到正在启动中的流程.而本方法正是在启动中的流程执行的,所以无法通过本方法当前流程中的元素
		
		List<Execution> list = runtimeService.createExecutionQuery().activityId("receive").list();
		
		for (Execution exec : list) {
			runtimeService.signal(exec.getId());
		}
        
	}

}
